package IONIO;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;

/** 
  * @author  outsider
  * @date 创建时间：2016年4月19日 下午11:05:21 
  * @note
*/
public class NIO {
   public static void main(String args[]){
			try{
				
				FileChannel in = new FileInputStream(new File("D:\\CD.rar")).getChannel();	
				FileChannel out = new FileOutputStream(new File("D:\\CDnew.rar")).getChannel();

 				ByteBuffer buffer = ByteBuffer.allocate(102400000);
                int flag;				
				while((flag=in.read(buffer)) != -1){
					buffer.flip(); // Prepare for writing
					System.out.println(flag);
					out.write(buffer);
					buffer.clear();// Prepare for reading
				}

				out.close();
				in.close();
			}catch(Exception e){
				System.out.println("Exception");
			}	
		}
   
}
